//
//  LightningSetViewController.m
//  LINNER
//
//  Created by wei wang on 2017/3/30.
//  Copyright © 2017年 weiwang. All rights reserved.
//

#import "LightningSetViewController.h"
#import "BurnViewController.h"
#import "UserManualViewController.h"
#import "LightningUpdateViewController.h"
#import "Masonry.h"

@interface LightningSetViewController ()<UITableViewDelegate,UITableViewDataSource>
/** Array **/
@property(nonatomic,strong) NSArray *titleArray;
@property (strong, nonatomic) UITableView *tableView;

@end

@implementation LightningSetViewController
- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    [self setNavigationStyle];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self masLayoutSubview];
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self.view;
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(superView.mas_bottom);
        make.right.mas_equalTo(superView.mas_right);
        make.left.mas_equalTo(superView.mas_left);
        make.top.mas_equalTo(superView.mas_top).mas_offset(64);
    }];
}

- (void)setNavigationStyle{
    
    [self setNavigationBarTitle:MyNSLocalizedString(@"NC21 Lightning")];
    [self setLeftButtonImage:[UIImage imageNamed:@"tittle_back_nor"]];
    [self.navigationController.navigationBar makeTransparent_nornav];
    
}

#pragma mark - --------------------------UITableView dataSource--------------------------

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.textColor = [UIColor colorWithHexString:@"#56504f"];
        [cell.textLabel setFont:[UIFont systemFontOfSize:15.f]];
    }
    cell.textLabel.text = MyNSLocalizedString(self.titleArray[indexPath.row]);

       return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 56;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return CGFLOAT_MIN;
    
}
#pragma mark - --------------------------UITableView delegate--------------------------

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if (indexPath.row == 0) {
        BurnViewController *vc = [BurnViewController new];
        vc.indexTag = 0;
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 1){
    
        LightningUpdateViewController *vc = [LightningUpdateViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }else{
        
        UserManualViewController *vc = [UserManualViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
    
}

- (UITableView *)tableView{
    
    if (!_tableView) {
        
        __weak UIView *superView = self.view;
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        [superView addSubview:_tableView];
        //        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;//隐藏tableView的分割线
        //        _tableView.scrollEnabled = NO;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor clearColor];
    }
    
    return _tableView;
    
}

- (NSArray *)titleArray{
    
    if (!_titleArray) {
        
        _titleArray = @[@"煲机模式",@"固件升级",@"使用说明"];
    }
    return _titleArray;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
